package com.pp.controller;


import com.pp.bean.GovTop;
import com.pp.service.GovTopService;
import com.pp.util.Respons.ResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 导航 前端控制器
 * </p>
 *
 * @author 冯政尚
 * @since 2019-04-02
 */
@Controller
@RequestMapping("/govTop")
@Api(value = "导航Controller", tags = {"导航类型类"})
public class GovTopController {


    @Autowired
    GovTopService govTopService;


    @RequestMapping(value = "insert",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "新增导航")
    public Map insert(@RequestBody GovTop govTop){
        if(govTopService.save(govTop)){
            return ResponseUtil.getSuccessMap();
        }
        return ResponseUtil.getExceptionMap();
    }


    @RequestMapping(value = "updateById",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "修改导航")
    public Map updateById(@RequestBody GovTop govTop){
        if(govTopService.updateById(govTop)){
            return ResponseUtil.getSuccessMap();
        }
        return ResponseUtil.getExceptionMap();
    }

    @RequestMapping(value = "deleteById",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "删除导航")
    public Map deleteById(@RequestBody GovTop govTop){
        Map map = new HashMap();
        if(govTopService.removeById(govTop)){
            return ResponseUtil.getSuccessMap();
        }
        return ResponseUtil.getExceptionMap();
    }

    @RequestMapping(value = "select",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询导航")
    public List<GovTop> select(){
        return govTopService.list();
    }



}
